Filter hook 'get_{$adjacent}_post_excluded_terms'

in WP Core File wp-includes/link-template.php at line 1880

View Source

get_{$adjacent}_post_excluded_terms

Filter Hook
Description
Filters the IDs of terms excluded from adjacent post queries. The dynamic portion of the hook name, `$adjacent`, refers to the type of adjacency, 'next' or 'previous'. Possible hook names include: - `get_next_post_excluded_terms` - `get_previous_post_excluded_terms`

Hook Information

File Location wp-includes/link-template.php View on GitHub
Hook Type Filter
Line Number 1880

Hook Parameters

Type Name Description
int[]|string $excluded_terms Array of excluded term IDs. Empty string if none were provided.

Usage Examples

Basic Usage
<?php
// Hook into get_{$adjacent}_post_excluded_terms
add_filter('get_{$adjacent}_post_excluded_terms', 'my_custom_filter', 10, 1);

function my_custom_filter($excluded_terms) {
    // Your custom filtering logic here
    return $excluded_terms;
}

Source Code Context

wp-includes/link-template.php:1880 - How this hook is used in WordPress core
<?php
1875  	 *
1876  	 * @since 4.4.0
1877  	 *
1878  	 * @param int[]|string $excluded_terms Array of excluded term IDs. Empty string if none were provided.
1879  	 */
1880  	$excluded_terms = apply_filters( "get_{$adjacent}_post_excluded_terms", $excluded_terms );
1881  
1882  	if ( $in_same_term || ! empty( $excluded_terms ) ) {
1883  		if ( $in_same_term ) {
1884  			$join  .= " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
1885  			$where .= $wpdb->prepare( 'AND tt.taxonomy = %s', $taxonomy );

PHP Documentation

<?php
/**
	 * Filters the IDs of terms excluded from adjacent post queries.
	 *
	 * The dynamic portion of the hook name, `$adjacent`, refers to the type
	 * of adjacency, 'next' or 'previous'.
	 *
	 * Possible hook names include:
	 *
	 *  - `get_next_post_excluded_terms`
	 *  - `get_previous_post_excluded_terms`
	 *
	 * @since 4.4.0
	 *
	 * @param int[]|string $excluded_terms Array of excluded term IDs. Empty string if none were provided.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/link-template.php
Related Hooks

Related hooks will be displayed here in future updates.